package org.example.gxpt.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.gxpt.common.result.Result;
import org.example.gxpt.pojo.dto.LoginByPhoneDTO;
import org.example.gxpt.pojo.dto.LoginDTO;
import org.example.gxpt.pojo.vo.LoginVO;
import org.example.gxpt.pojo.vo.UserLoginVO;
import org.example.gxpt.service.LoginService;
import org.example.gxpt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@Slf4j
@Api(tags = "统一登录接口")
@CrossOrigin
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    @ApiOperation("用户名统一登陆")
    public Result userLogin(@RequestBody LoginDTO loginDTO){
        LoginVO LoginVO = loginService.login(loginDTO);
        return Result.success(LoginVO);
    }

    @PostMapping("/loginByPhone")
    @ApiOperation("手机号统一登陆")
    public Result userLoginByPhone(@RequestBody LoginByPhoneDTO loginByPhoneDTO){
        LoginVO LoginVO = loginService.loginByPhone(loginByPhoneDTO);
        return Result.success(LoginVO);
    }
}
